Ext.onReady(function(OutStockEditorGrid){
	
	var viewConfig = [{
		columnsText: '显示列',
		sortAscText: '升序',
		sortDescText: '降序'
	}];
	var sm = new Ext.grid.CheckboxSelectionModel({
		singleSelect : false
	});
	
    var cm = new Ext.grid.ColumnModel([sm,
		{header : '物料名称', dataIndex : 'materielName'}, 
		{header : '所属部门', dataIndex : 'uname'}, 
		{header : '库存数量', dataIndex : 'amount'}, 
		{header : '属性1',    dataIndex : 'attrib1',hidden:true},
		{header : '属性2',    dataIndex : 'attrib2',hidden:true},
		{header : '属性3',    dataIndex : 'attrib3',hidden:true},
		{header : '属性4',    dataIndex : 'attrib4',hidden:true},
		{header : '属性5',    dataIndex : 'attrib5',hidden:true},
		{header : '价格',     dataIndex : 'cost',hidden:true}
    ]);
    
	cm.defaultSortable = true;

    var store = new Ext.data.Store({
       baseParams : {
			trancode : '12137'
		},
		proxy : new Ext.data.HttpProxy({
			url : '../' + WebServiceUrl
		}),
		reader : new Ext.data.JsonReader({
			totalProperty : 'totalProperty',
			root : 'root'
		},  
        [{name : 'id'},
        {name : 'uid'},
        {name : 'idt_materiel'}, 
        {name : 'amount'},
		{name : 'attrib1'}, 
		{name : 'attrib2'}, 
		{name : 'attrib3'}, 
		{name : 'attrib4'}, 
		{name : 'attrib5'}, 
		{name : 'cost'},
		{name : 'uname'},
		{name : 'materielName'}
		])
    });

    
    var grid = new Ext.grid.GridPanel({
    	id:'selectMaterielGrid',
		store: store,
		autoScroll:true,
		cm: cm,
		sm: sm,
		border:false,
		bbar: new Ext.PagingToolbar({
			pageSize : App.pageSize,
            store: store,
            displayInfo: true,
            displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
        	emptyMsg: "没有记录"
        }),
		tbar:['条件：', {
				xtype : "textfield",
				id : 'condition',
				width:100,
				selectOnFocus : true
			}, '-', {
				text : '查询',
				tooltip : '查询',
				handler : doSearch,
				iconCls : 'search'
			},'-',{
				text : '打印',
				tooltip : '打印',
				handler : onPrint,
				iconCls : 'print'
			}
		],
		bbar: new Ext.PagingToolbar({
            store: store,
            pageSize:App.pageSize,
            displayInfo: true,
            displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
        	emptyMsg: "没有记录"
        }),
        viewConfig:viewConfig,
		loadMask: true
    });
    store.load({params : {start : 0,limit : App.pageSize}});
	
    var viewport = new Ext.Viewport({
        layout:'border',
        id:'viewport',
        split:true,
		items:[{
			split:true,
			collapsible:true,
			border:false,
			region:'center',
			layout:'fit',
			items:grid
		}]
	});
	function onPrint(){
		openBrWindow('../reportJsp/showReport.jsp?raq=AllStockQuery','打印');
	}
	function doSearch(){
		var condition = Ext.get('condition').getValue();//条件
		store.baseParams = {
			condition : condition,
			trancode : '12137'
		};
		store.reload();
	}
})